	var s,m,h,cnt,ss,t,curr=0;
	var tprogress,tcheckplaying,tshowtime;
	function set() {
		curr=Math.round(media.input.time);
		if (cnt==0) { ss=0; t=curr; cnt++; printtime(ss,t); }
		else { ss=t; t=curr; cnt++; printtime(ss,t); }
		return true;
	}
	function mark() {
		curr=Math.round(media.input.time);
		if ($("#mark").val()=='Mark In') { ss=curr; $("#mark").val("Mark Out"); }
		else if ($("#mark").val()=='Mark Out') { 
		if (t<=ss) { alert("The duration of the clip has to be a minimum of 1 second!"); return false; }
		t=curr; printtime(ss,t); $("#mark").val("Mark In"); cnt++; }
		return true;
	}
	function printtime(pss,pt) {
		var stt,spt;
		$("#ff").append('ffmpeg -i  "'+ infile +'" -ss ' + pss/1000 + ' -t ' + pt/1000 + " \n");
		if (pss==0) stt="00:00:00"; else stt = formattime(pss/1000);
		if (pss==0) spt="00:00:00"; else spt = formattime(pt/1000);
		$("#timelist").append('<li>'+ stt + ' - ' + spt + ' - <input type="text" name="clipnames[]" size="20" value="Clip" /></li>');
		return true;
	}
	function formattime(scs) {
		var tm;
		var gs,gm,gh=0;
		gh=Math.floor(scs/3600);
		gm=Math.floor((scs%3600)/60);
		gs=Math.floor(scs%60);
		if (gs<10) var gss="0"+gs; else var gss=gs;
		if (gm<10) var gsm="0"+gm; else var gsm=gm;
		if (gh<10) var gsh="0"+gh; else var gsh=gh;
		tm = gsh + ":" + gsm + ":" + gss;
		return tm;
	}
	function seek(seconds) {
		var gototime=prompt("Enter the time [hh:mm:ss (or) mm:ss (or) ss]"); 
		var tarr=gototime.split(':');
		switch(tarr.length) {
			case 3:
				var timetogo=(tarr[0]*3600)+(tarr[1]*60)+(tarr[2]*1);
			break;
			case 2:
				var timetogo=(tarr[0]*60)+(tarr[1]*1);
			break;
			default:
				if (isNaN(gototime)==false)
					timetogo=gototime*1;
				else { 
					alert("Please enter a valid time stamp!");
					return false;
				}
			break;
		}
		timetogo=timetogo*1000;
		if (timetogo>=media.input.length) {alert("Please enter a valid time stamp!"); return false; }
		media.input.time = timetogo;
		document.getElementById("progress").style.width=(media.input.position*100) + "%";
		return true;
	}
	function playpause() {
		document.getElementById("stop").disabled="";
		if (media.playlist.isPlaying==false) { 
			media.playlist.play();
			setTimeout("properties()",500);
			setTimeout("showtime()",500);
			subcontrols("enable");
			media.audio.volume=200;
		}
		else { 
			media.playlist.togglePause();
			if (media.playlist.isPlaying==true) subcontrols("enable");
			else subcontrols("disable");
		}
		setTimeout("checkplaying()",500);
		progress();
		return true;
	}
	function playerstop() {
		media.playlist.stop();
		$("#time").text("00:00:00");
		subcontrols("disable");
		document.getElementById("stop").disabled="disabled";
		document.getElementById("progress").style.width="0px";
		return true;
	}
	function properties() {
		if (media.playlist.isPlaying==true) { 
			$("#len").text(formattime(media.input.length/1000));
		}
		if (media.input.hasVout==true) {
			var ar=media.video.width/media.video.height;
		}
	}
	function showtime() {
		$("#time").text(formattime(media.input.time/1000));
		var pos=media.input.position*100;
		setTimeout("showtime()",500);
		return true;
	}
	function subcontrols (action) {
		if (action=="disable") {
			document.getElementById("mark").disabled="disabled";
			document.getElementById("set").disabled="disabled";
			document.getElementById("gototime").disabled="disabled";
			document.getElementById("stop").disabled="disabled";
		}
		else {
			document.getElementById("mark").disabled="";
			document.getElementById("set").disabled="";
			document.getElementById("gototime").disabled="";
			document.getElementById("stop").disabled="";
		}
	}
	function checkplaying() {
		if (media.playlist.isPlaying==false) {
			// $("#time").text("00:00:00");
			subcontrols("disable");
			// document.getElementById("progress").style.width="0px";
		}
		else {
			subcontrols("enable");
		}
		setTimeout("checkplaying()",500);
	}
	function progress() {
		if (media.playlist.isPlaying==true)
			document.getElementById("progress").style.width=(media.input.position*100) + "%";
			tprogress=setTimeout("progress()",500);
	}
	function mouseseek() {
		if (media.playlist.isPlaying==true) {
			var elpos = document.getElementById("pos");
			var seekbar = PageInfo.getElementWidth("pos");
			var clickpos = PageInfo.getMouseX() - PageInfo.getElementLeft("pos");
			media.input.position=clickpos/seekbar;
		}
	}
	function vol(act) {
		var vol=media.audio.volume;
		if (act=="+" && vol < 200)	media.audio.volume=vol+20;
		else if (act=="-" && vol > 0)	media.audio.volume=vol-20;
	}